﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NF_IDAL;
using NF_Mode;
using System.Data;
using Dapper;

namespace NF_DAL
{
    public class UserLogin_DAL<T> where T : class
    {

        public static dynamic LoingByPassword(SysUser us, ref BaseAnswer bar)
        {
            var param = new DynamicParameters();
            param.Add("@UserName", us.us_UserName);
            param.Add("@UserPass", us.us_Password);
            param.Add("@SysMessage", "", DbType.String, ParameterDirection.Output);
            param.Add("@SysSucess", 0, DbType.Int32, ParameterDirection.Output);


            var lst = DapperProcedure<T>.DoProcedureNoParme("SysUserLogin", param, ref bar).ToList<T>();
            if (bar.AnswerType != BaseAnswer.Answers.Error)
            {
                bar.AnswerMeg = (string)param.Get<object>("@SysMessage");
                bar.AnswerType = Convert.ToInt32(param.Get<object>("@SysSucess")) == 1 ? BaseAnswer.Answers.Succee : BaseAnswer.Answers.Failure;
            }

            return lst;
        }

    }
}
